package net.zigin.nhi.could.waste.rabbitmq;

import net.zigin.nhi.could.waste.rabbitmq.model.MessageModel;
import net.zigin.nhi.could.waste.config.RabbitMqConfig;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Producers {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(MessageModel messageModel, String routingKey, Long time) {
        // 参数 类型 时间 医废实体
        this.rabbitTemplate.convertAndSend(RabbitMqConfig.exchangeName, routingKey, messageModel, message -> {
            message.getMessageProperties().setExpiration(time + "");
            return message;
        });

    }


}
